<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    var ips=['1.1.1.19','1.1.1.2','9.1.1.2','9.1.1.199'];
    ips=function(){
        var list=[],length=100;
        while(length--){
            console.log(length)
            list.push((Math.random()*20|0)+'.'+(Math.random()*20|0)+'.'+(Math.random()*20|0)+'.'+(Math.random()*20|0))
        };
        return list;
    }();
    console.log(ips);

    ips.sort(function (a,b) {
        var s1,s2;
        a= a.split('.');
        b= b.split('.');
        for(var i= 0;i<4;i++){
            s1=a[i]*1;
            s2=b[i]*1;
            if(s1<s2)return -1;
            if(s1>s2)return 1;
        }
        return 0;
    });

    console.log(ips);
</script>
</body>
</html>